package com.SouthernWall_404.Age_Capitalism.common.World.Items;

import com.SouthernWall_404.Age_Capitalism.common.API.WalletAPI;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class WalletItem extends Item {

    private int maxAmount;


    public WalletItem(Properties properties, int maxAmount) {
        super(properties);
        this.maxAmount = maxAmount;
    }

//    @Override
//    public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
//
//        ItemStack itemStack=player.getItemInHand(hand);
//        if(itemStack.getItem()instanceof WalletItem)
//        {
//            WalletContains walletContains=WalletAPI.read(itemStack);
//            WalletAPI.put(itemStack,
//                    new WalletContains(
//                            walletContains.amount_100+100,
//                            50,
//                            20,
//                            10,
//                            5,
//                            1,
//                            5,
//                            1
//                    )
//            );
//            //WalletAPI.showAmount(player,itemStack);
//
//        }
//
//        return super.use(level, player, hand);
//
//
//    }


    @Override
    public void appendHoverText(ItemStack itemStack, @Nullable Level p_41422_, List<Component> tooltip, TooltipFlag flag) {

        if (Screen.hasShiftDown()) {

            super.appendHoverText(itemStack, p_41422_, tooltip, flag);
            tooltip=addTooltip(tooltip,itemStack);
        }
        else
        {
            super.appendHoverText(itemStack, p_41422_, tooltip, flag);
        }


    }
    public List<Component> addTooltip(List<Component> tooltip,ItemStack itemStack)
    {
        tooltip.add(Component.translatable("total:"+WalletAPI.read(itemStack).total)
                .withStyle(style -> style.withColor(ChatFormatting.GRAY)));
        return tooltip;
    }


}
